package operations;

import book.BookList;

import java.util.Scanner;

public class FindOperation implements Ioperation{
    @Override
    public void work(BookList bookList) {
        //遍历数组，如果查询到图书信息则打印。如果没有查询到则提示没有该图书信息
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入你想要查找的书名");

        String inputBookName = sc.nextLine();
        int i = 0;
        for (; i < bookList.getUsedSize(); i++) {
            if(bookList.getBooks()[i].getName().equals(inputBookName)){
                System.out.println("查找成功！您要查找的图书信息如下:");
                System.out.println(bookList.getBooks()[i]);
                break;
            }
        }

        if(i == bookList.getUsedSize()) {
            System.out.println("没有查找到您输入的图书信息！");
        }
    }
}
